(function($){
	function clickTab(target,index,fn){
		var tabs = $('._tabs li',target);
		$(tabs[index-1]).bind('click',fn);
	};
	function getTab(target,index){
	    var tabs = $('._tabs li',target);
	    var tab = tabs.get(index);
	    return $(tab);
	};
	$.fn.tabpane = function(options,params){
		if(options == null){
			var me = $(this);
			$('._tabs').addClass('class_title');
		    $(this).attr('selectedIndex',0);
		    $(this).attr('selectedTabClass','ahover');
			var tabs = $('._tabs li',$(this));
			var panes = $('._tabpanes>div',$(this));
			$(tabs[0]).addClass(me.attr('selectedTabClass'));
			$.each(tabs,function(index,tab){
				$(panes[index]).addClass('');
				if(index!==0){
					$(panes[index]).css('display','none');
				}
				$(tab).wrapInner('<span></span>');
				$(tab).bind('click',function(){
					if(index!==me.attr('selectedIndex')){
						$(tabs[me.attr('selectedIndex')]).removeClass(me.attr('selectedTabClass'));
						$(tabs[index]).addClass(me.attr('selectedTabClass'));
						$(panes[me.attr('selectedIndex')]).hide();
						$(panes[index]).fadeIn(800);
						me.attr('selectedIndex',index);
					}
				});
			})
		}
		else if(options == "clickTab"){
			return clickTab(this,arguments[1],arguments[2]);
		}
		else if(options == "getTab"){
		    return getTab(this,arguments[1]);
		}
		
	}
})(jQuery);